﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace LEET.Application
{
    public class ConsoleMessageBox
    {
        static public MessageBoxResult Show(Window owner, string message)
        {
            return MessageBox.Show(owner, message, string.Empty, MessageBoxButton.OK);
        }

        static public MessageBoxResult Show(Window owner, string message, string title, MessageBoxImage image)
        {
            return MessageBox.Show(owner, message, title, MessageBoxButton.OK, image);
        }

        static public MessageBoxResult Show(Window owner, string message, string title)
        {
            Window window = new Window();

            window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            window.Topmost = true;
            window.Focusable = true;
            window.FocusableChanged +=new DependencyPropertyChangedEventHandler(FocusWindow);

            window.Activate();
            window.Hide();
            MessageBoxResult result = Show(window, message, "Informational", MessageBoxImage.Asterisk);
            window.Close();

            return result;
        }

        private static void FocusWindow(object sender, DependencyPropertyChangedEventArgs e)
        {
            ((Window)sender).Hide();
        }

        //private static void BoxOpened(object sender, RoutedEventArgs e)
        //{
        //    ((Window)sender).Focus();
        //    ((Window)sender).Topmost = true;
        //    ((Window)sender).BringIntoView();
        //}

        //private static void BoxVisibility(object sender, DependencyPropertyChangedEventArgs e)
        //{
        //    ((Window)sender).Focus();
        //    ((Window)sender).Topmost = true;
        //    ((Window)sender).BringIntoView();
        //}

        //private static void BoxInit(object sender, EventArgs e)
        //{
        //    ((Window)sender).Focus();
        //    ((Window)sender).Topmost = true;
        //    ((Window)sender).BringIntoView();
        //}
    }
}
